//
//  UIImage+YSRounderCorners.h
//  YSKitExample
//
//  Created by Kyson on 2017/6/16.
//  Copyright © 2017年 YangShen. All rights reserved.
//

#import <UIKit/UIKit.h>

typedef struct _YSCornersRadius {
    CGFloat topLeftCornersRadius;
    CGFloat topRightCornersRadius;
    CGFloat bottomLeftCornersRadius;
    CGFloat bottomRightCornersRadius;
} YSCornersRadius;

static inline YSCornersRadius YSCornersRadiusMake(CGFloat topLeftCornersRadius, CGFloat topRightCornersRadius, CGFloat bottomLeftCornersRadius, CGFloat bottomRightCornersRadius) {
    YSCornersRadius cornersRadius;
    cornersRadius.topLeftCornersRadius = topLeftCornersRadius;
    cornersRadius.topRightCornersRadius = topRightCornersRadius;
    cornersRadius.bottomLeftCornersRadius = bottomLeftCornersRadius;
    cornersRadius.bottomRightCornersRadius = bottomRightCornersRadius;
    return cornersRadius;
}

static inline NSString * NSStringFromysCornersRadius(YSCornersRadius cornersRadius) {
    return [NSString stringWithFormat:@"{%.2f, %.2f, %.2f, %.2f}", cornersRadius.topLeftCornersRadius, cornersRadius.topRightCornersRadius, cornersRadius.bottomLeftCornersRadius, cornersRadius.bottomRightCornersRadius];
}

typedef void(^YSRounderCornersCompletedBlock)(UIImage *image);

@interface UIImage (YSRounderCorners)

- (void)ys_setRounderCornersSize:(CGSize)size completed:(YSRounderCornersCompletedBlock)completedBlock;
- (void)ys_setCornersRadius:(CGFloat)cornerRadius size:(CGSize)size completed:(YSRounderCornersCompletedBlock)completedBlock;
- (void)ys_setCornersRadius:(CGFloat)cornerRadius
                       size:(CGSize)size
                borderColor:(UIColor *)borderColor
                borderWidth:(CGFloat)borderWidth
                  completed:(YSRounderCornersCompletedBlock)completedBlock;
- (void)ys_setCornersRadius:(YSCornersRadius)cornerRadius
                       size:(CGSize)size
                borderColor:(UIColor *)borderColor
                borderWidth:(CGFloat)borderWidth
                contentMode:(UIViewContentMode)contentMode
                  completed:(YSRounderCornersCompletedBlock)completedBlock;

+ (void)ys_setCornersRadius:(YSCornersRadius)cornersRadius
                       size:(CGSize)size
                borderColor:(UIColor *)borderColor
                borderWidth:(CGFloat)borderWidth
            backgroundColor:(UIColor *)backgroundColor
                  completed:(YSRounderCornersCompletedBlock)completedBlock;
+ (void)ys_setCornersRadius:(YSCornersRadius)_cornersRadius
                      image:(UIImage *)_image
                       size:(CGSize)size
                borderColor:(UIColor *)borderColor
                borderWidth:(CGFloat)borderWidth
            backgroundColor:(UIColor *)_backgroundColor
            withContentMode:(UIViewContentMode)contentMode
                  completed:(YSRounderCornersCompletedBlock)completedBlock;

@end
